package com.goldsprite.gdxcore.assets.utils;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;

public class JarUtils {
    public static String getActualAssetsPath(String assetPath) {
        String path = assetPath;
        if (isRunningInJar()){
            path = "assets/" + assetPath;
        }
        return path;
    }
    public static FileHandle getActualFilesInternal(String assetPath) {
        return Gdx.files.internal(getActualAssetsPath(assetPath));
    }

    public static boolean isRunningInJar() {
        String classPath = System.getProperty("java.class.path");
        String protocol = JarUtils.class.getResource("").getProtocol();
        return "jar".equals(protocol) || classPath.contains(".jar!");
    }

    public static void main(String[] args) {
        System.out.println(JarUtils.getActualAssetsPath("AA"));
    }
}
